//
//  UserMessageViewController.m
//  StraightTrain
//
//  Created by mk on 15/11/24.
//  Copyright (c) 2015年 mk. All rights reserved.
//

#import "UserMessageViewController.h"
#import "UserBasicMessViewController.h"
#import "SignExpertMainViewController.h"
#import "RealNameAuthenticationMainViewController.h"
@interface UserMessageViewController ()

@end

@implementation UserMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    titleLabel.text = @"个人信息";
    
    [btnExit setBackgroundImage:[[UIImage imageNamed:@"user_exit_btn.png"] stretchableImageWithLeftCapWidth:20 topCapHeight:20] forState:UIControlStateNormal];
    
}

#pragma mark 基本信息
-(IBAction)btnBasicWithInformation:(id)sender
{
    UserBasicMessViewController * base = [[UserBasicMessViewController alloc]initWithNibName:@"UserBasicMessViewController" bundle:nil];
    [self.navigationController pushViewController:base animated:YES];


}

#pragma mark 实名认证
-(IBAction)btnAuthenticationWithRealName:(id)sender
{
    RealNameAuthenticationMainViewController * name = [[RealNameAuthenticationMainViewController alloc]initWithNibName:@"RealNameAuthenticationMainViewController" bundle:nil];
    [self.navigationController pushViewController:name animated:YES];
    
}

#pragma mark 签约专家
-(IBAction)btnSignWithExperts:(id)sender
{
    BOOL isProfile = [[gProjConfig.dicUserData objectForKey:USER_isProfile] boolValue];
    if (isProfile)
    {
        SignExpertMainViewController * exper = [[SignExpertMainViewController alloc]initWithNibName:@"SignExpertMainViewController" bundle:nil];
        [self.navigationController pushViewController:exper animated:YES];
        
    }else
    {
        UIAlertView *alertNeedLogin = [[UIAlertView alloc] initWithTitle:alerTitle message:@"请到个人信息界面补全资料信息!" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
        alertNeedLogin.tag = 100;
        [alertNeedLogin show];
    }
    
}



-(IBAction)btnExitLoginStare:(id)sender
{

  AlertDelegate(alerTitle, @"确定退出当前登录状态么?", @"退出", @"取消")

}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag == 100)
    {
        if (alertView.cancelButtonIndex != buttonIndex)
        {
        UserBasicMessViewController * base = [[UserBasicMessViewController alloc]initWithNibName:@"UserBasicMessViewController" bundle:nil];
        [self.navigationController pushViewController:base animated:YES];
        }
        
    }else
    {
        if (alertView.cancelButtonIndex == buttonIndex)
        {
            [gProjConfig.dicUserData removeAllObjects];
            [gProjConfig.dicUserData setObject:@"" forKey:USER_tel];
            [gProjConfig.dicUserData setObject:@"" forKey:USER_token];
            [gProjConfig writeToFile:USERPROFILE_FILENAME writeData:gProjConfig.dicUserData];
            
            if ([self.delegate respondsToSelector:@selector(exitLogin)])
            {
                [self.delegate exitLogin];
            }
            
            [self.navigationController popViewControllerAnimated:YES];
        }
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
